/**
 * Created by futao on 16/01/19.
 */
angular.module('sbAdminApp')
    .service('settlementSchedulerCenterService',['$http','httpResource',  function ($http, httpResource) {
    	var func="sc/rpt/ssc/";
        
        this.search1 = function (taskName, beginDate,endDate, pageno, itempersize) {
       	    return  $http({
	             url: func+'list',
	             method: 'post',
	             params: {
	            	      taskName: taskName,
		            	  pageNo: pageno,
	          	          pageSize: itempersize,
	          	          beginTime: beginDate,
	           	          endTime: endDate
	          	       }
             });
        };
 
        this.add1 = function (taskName,currentMachine,threshold,tickTime) {
//        	alert("taskName=="+taskName+"  currentMachine="+currentMachine+" threshold="+threshold);
        	if(taskName==undefined ||
        			currentMachine==undefined || 
        			threshold==undefined ||
        			tickTime==undefined){
        		return 0;
        	}
       	    return  $http({
	             url: func+'add',
	             method: 'post',
	             params: { 
		            	      taskName: taskName,
		            	      currentMachine: currentMachine, 
		            	      threshold:threshold,
		            	      tickTime:tickTime
	            	     }
	          });
        };
        
        
        this.edit1 = function (id,tickTime,currentMachine,threshold) {
        	if(tickTime==undefined){
        		tickTime=null;
        	}
        	if(currentMachine==undefined){
        		currentMachine=null;
        	}
        	if(threshold==undefined){
        		threshold=null;
        	}
       	    return  $http({
	             url: func+'edit',
	             method: 'post',
	             params: { 
		            	      id: id,
		            	      tickTime: tickTime,
		            	      currentMachine: currentMachine, 
		            	      threshold:threshold
	            	     }
	          });
        };
        
        this.delete1 = function (id) {
       	    return  $http({
	             url: func+'delete',
	             method: 'post',
	             params: { 
		            	    id: id
	            	     }
	          });
        };
        
        
        
        
    }]);